package com.kbp.view.actions;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.kbp.beans.TestBean;
import com.kbp.model.User;
import com.kbp.service.TestService;
import com.opensymphony.xwork2.ActionSupport;

@ParentPackage(value = "kbp")
@InterceptorRef("jsonValidationWorkflowStack")
public class Test extends ActionSupport{
	
	private static final long serialVersionUID = 7348214863884222245L;
	@Action(value = "/test", results = { @Result(name = "success", type = "json") })
	public String execute() throws Exception {	
		User user = testService.get();
	//	User u = new User();
	////	u.setAccount("mmmmmmmmmmmmmm");
	//	this.user = u;
		tb.setMess(user.getOccupation());
		return SUCCESS;
	}
	public String getJSON() throws Exception {
		return execute();
	}
	private TestService testService;
	//private User user;
	private TestBean tb = new TestBean();
	
	
	public Test(TestService testService) {
		super();
		this.testService = testService;
	}
	public void setTb(TestBean tb) {
		this.tb = tb;
	}
	public TestBean getTb() {
		return tb;
	}	
}